<template>
    <div class="box">
        <h3>axios的集成和使用</h3>
        <p>{{ result }}</p>
        <input type="button" value="加载服务器" @click="LoadData()">
        <input type="button" value="加载服务器" @click="LoadData2()">
    </div>
</template>
<script>
import axios from 'axios'
export default {
    data() {
        return {
            result: {}
        }
    },
    methods: {
        LoadData() {
            axios.get("http://127.0.0.1:3000/public/types")
                .then((res) => {
                    console.log(res);

                    this.result = res.data.data
                })
        },
        async LoadData2() {
            try {
                let res = await axios.get("http://127.0.0.1:3000/public/types")
                this.result = res.data
            } catch (error) {
                console.log(error);
                
            }
        }
    },
    created(){
        this.LoadData2()
    }
}

</script>